<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    div居中<br />
    1.父元素text-align:center,该元素margin:0 auto;
    <div style="text-align: center;">
      <div
        style="height: 60px;width:60px;background:teal;margin: 0 auto;"
      ></div>
    </div>
    2.自己变为相对布局，左上都是50%，position: absolute;left: 50%;top: 50%;
    <div
      style="height: 60px;width:60px;background:hotpink;position: absolute;left: 50%;top: 50%;"
    ></div>
  </body>
</html>
